import $ from 'jquery'


var eleDustbin = $('.dustbin');
var eleDrags = $('.draglist')
var lDrags = eleDrags.length;
var eleRemind = $('.dragremind')
var eleDrag = null;

// 开始拖拽
eleDrags.on('dragstart', function (e) {
    console.log(e);
    e.originalEvent.dataTransfer.effectAllowed = "move";
    e.originalEvent.dataTransfer.setData("text", e.target.innerHTML);
    e.originalEvent.dataTransfer.setDragImage(e.target, 0, 0);
    eleDrag = e.target;
    return true;
})

eleDrags.on('dragend', function (e) {
    e.originalEvent.dataTransfer.clearData("text");
    eleDrag = null;
    return false
})
eleDustbin.on('dragover', function (e) {
    e.preventDefault();
})
// 进入"垃圾箱"
eleDustbin.on('dragenter', function(e){
    var target = $(e.currentTarget);
    target.css('color', '#ffffff')
    return true;
})
// 拖拽到"垃圾箱" 放开
eleDustbin.on('drop', function(e){
    var target = $(e.currentTarget);
    if (eleDrag) {
        eleRemind.html('<strong>"' + eleDrag.innerHTML + '"</strong>被扔进了垃圾箱') ;
        eleDrag.remove();
    }
    target.css('color', '#000000')
    return false;
})